package com.service;

import com.mapper.UserMapper;
import com.pojo.User;
import com.utils.ResultCodeEnum;
import com.utils.exception.exceptionExtend.NoFindUserException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

@Service
public class UserService {
    @Autowired
    private UserMapper userMapper;

    public List<User> list(){
//      int i = 1/0;
        return Collections.emptyList();
    }

    public List<User> queryAll(){
       return userMapper.queryAll();
    }

    public int add(User user){
        return add(user);
    }

    public int del(Integer id){
        return del(id);
    }

    public int update(User user){
        return update(user);
    }


    public User queryOne(Integer id){
        User user = userMapper.queryOne(id);
        if(user == null)
          throw new NoFindUserException();
        return user;
    }
}
